package com.hzncc.scaffold.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.hzncc.scaffold.entity.Other.Assessment;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hzncc.scaffold.entity.Bo.AssessmentDetailBo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 评估表 Mapper 接口
 * </p>
 *
 * @author DrunkBear
 * @since 2022-04-27
 */
public interface AssessmentMapper extends BaseMapper<Assessment> {

    @Select("SELECT\n" +
            "\t`assessment`.`id`,\n" +
            "\t`assessment`.`title`,\n" +
            "\t`assessment`.`content`,\n" +
            "\t`assessment`.`createTime`,\n" +
            "\t`user`.`id` AS `userId`,\n" +
            "\t`user`.`name` AS `userName`,\n" +
            "\t`user`.`account` AS `userAccount`,\n" +
            "\t`user`.`realname` AS `userRealname`,\n" +
            "\t`user`.`instituteName` AS `userinstituteName`,\n" +
            "\t`user`.`idCardNum` AS `userIdCardNum`,\n" +
            "\t`user`.`telephone` AS `userTelephone` \n" +
            "FROM\n" +
            "\t`assessment` AS `assessment`\n" +
            "\tLEFT OUTER JOIN `user` AS `user` ON `assessment`.`userId` = `user`.`id` ${ew.customSqlSegment}")
    public AssessmentDetailBo detail(@Param(Constants.WRAPPER) QueryWrapper queryWrapper);



    @Select("SELECT\n" +
            "\tassessment.* ,\n" +
            "\t`user`.`name` As userName\n" +
            "FROM\n" +
            "\t`assessment`\n" +
            "LEFT JOIN `user` ON assessment.userId = `user`.id ${ew.customSqlSegment}")
    public List<Assessment> listVo(@Param(Constants.WRAPPER) QueryWrapper queryWrapper);
}
